var express = require("express");
var app = express();
var session = require("express-session");

app.use(session({
    secret: 'keyboard cat',
    resave: false,
    saveUninitialized: true,
}))

app.get("/",function(req,res){
    if(req.session.login){
        res.send("欢迎您" + req.session.username);
    }else{
        res.send("丑八怪没有登录！");
    }
})

app.get("/login",function(req,res){
    req.session.login = true;
    req.session.username = "william";
    res.send("你已经成功登录！");
});

app.listen(3000);